﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="EventList.aspx.cs" Inherits="LizzabethBrownRealEstate.Views.Admin.EventList" %>
<%@ Import Namespace="LizzabethBrownRealEstate.Models" %>
<%@ Import Namespace="LizzabethBrownRealEstate.Controllers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
    <script type="text/javascript">
    
        function setFeatured(newsItemId, featured){
            $.getJSON("../Admin.ashx/SetFeaturedNewsItem?newsItemId=" + newsItemId + "&featured=" + featured);
        }
        
        $(document).ready(function(){
            jQuery().ajaxStart(function(){
	            $("#Progress").css('display', 'inline');
	            });

            jQuery().ajaxStop(function(){
	            $("#Progress").css('display', 'none');
	            });
        });
        
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <div class="contentDiv" style="margin-left:15%; margin-top:25px; width: 500px; ">
        <fieldset style="margin-bottom: 20px; width: 450px;">
            <legend>News Items</legend>
            <% LBRDataContext c = new LBRDataContext(); %>
            <table width="100%" style="border-collapse:collapse;">
            <% foreach (NewsItem n in c.NewsItems.Where<NewsItem>(n => n.Deleted == false))
               {%>
               <tr style="cursor:pointer" >
                    <td><%= Html.Encode(n.Title) %></td>
                    <% object attr = new { onclick = "setFeatured('" + n.NewsItemId.ToString() + "','" + n.Featured.ToString() + "')" };  %>
                    <td><%=Html.CheckBox("Featured", n.Featured.GetValueOrDefault(), attr) %></td>
                    <td><a href='<%= Url.Action("EditNewsItem", new { Controller = "Admin", newsItemId = n.NewsItemId })%>' class="linktableButton">Edit</a></td>
                    <td><a onclick="javascript:return confirm('Delete this item?')" href='<%= Url.Action("DeleteNewsItem", new { Controller = "Admin", newsItemId = n.NewsItemId })%>' class="linktableButton">Delete</a></td>
               </tr>
            <%} %>
            </table>
        </fieldset>
        
        <div>
            <button name="btnCancel" onclick="window.location ='../Admin.ashx/AdminOptions'; return false;">Return</button><div style="display:inline"><img id="Progress" src="../Content/Images/progress_bar.gif" style="display:none; position:relative;" alt="Please wait..." /></div>
        </div>
    </div>
</asp:Content>
